#include "toolkit.h"

#include <stdlib.h>

void Toolkit::GetVertices(const BoundingBox* boundingBox, Vector4* vertices) {
    vertices[0] = Vector4(boundingBox->min.x, boundingBox->min.y, boundingBox->min.z, 1.0f);
    vertices[1] = Vector4(boundingBox->min.x, boundingBox->max.y, boundingBox->min.z, 1.0f);
    vertices[2] = Vector4(boundingBox->max.x, boundingBox->max.y, boundingBox->min.z, 1.0f);
    vertices[3] = Vector4(boundingBox->max.x, boundingBox->min.y, boundingBox->min.z, 1.0f);
    vertices[4] = Vector4(boundingBox->max.x, boundingBox->max.y, boundingBox->max.z, 1.0f);
    vertices[5] = Vector4(boundingBox->min.x, boundingBox->max.y, boundingBox->max.z, 1.0f);
    vertices[6] = Vector4(boundingBox->min.x, boundingBox->min.y, boundingBox->max.z, 1.0f);
    vertices[7] = Vector4(boundingBox->max.x, boundingBox->min.y, boundingBox->max.z, 1.0f);
}

double Toolkit::RandomFloat() {
    return rand() / (static_cast<double>(RAND_MAX) + 1.0);
}

double Toolkit::RandomFloat(double min, double max) {
    if (min > max) {
        double temp = min;
        min = max;
        max = temp;
    }

    return (rand() / (static_cast<double>(RAND_MAX) + 1.0)) * (max - min) + min;
}

int Toolkit::RandomInt() {
    return rand();
}

int Toolkit::RandomInt(int min, int max) {
    if (min > max) {
        int temp = min;
        min = max;
        max = temp;
    }

    return rand() % (max - min + 1) + min;
}
